<?php

use think\Facade\Route;
use think\Facade\Env;

Route::domain(Env::get('app.api_url'), function () {
    header("Access-Control-Allow-Origin: *");
    header('Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE, HEAD, PATCH');
    header("Access-Control-Allow-Headers: token,tokens,language, Origin, X-Requested-With, Content-Type, Accept");
    Route::miss(function () {
        $result = [
            'code' => 1,
            'msg'  => '接口不存在',
            'time' => time(),
            'data' => [],
        ];
        return json($result);
        exit();
    });
    Route::group('User', function () {
        Route::post('login', '/login'); //登录
        Route::post('dylogin', '/dylogin'); //登录
        Route::post('mlogin', '/mlogin'); //手机号授权登陆
        Route::get('info', '/info'); //登录
        Route::rule('address', '/address'); //地址管理
        Route::rule('cart', '/cart'); //地址管理
        Route::post('cart_del', '/cart_del'); //地址管理
        Route::post('address_del', '/address_del'); //地址管理
        Route::get('qrcode', '/qrcode'); //二维码
        Route::get('getcoupon', '/getcoupon'); //二维码
        Route::post('putorder', '/putorder'); //订单提交
        Route::post('buyuser', '/buyuser'); //购买会员
        Route::post('orderstatus', '/orderstatus'); //状态变更
        Route::get('orderlist', '/orderlist'); //订单列表
        Route::post('checkorder', '/checkorder'); //订单列表
        Route::get('orderdetail', '/orderdetail'); //订单列表
        Route::post('setmobile', '/setmobile'); //获取手机号
        Route::get('userlevel', '/userlevel'); //购买会员信息
        Route::get('integrallog', '/integrallog'); //积分记录
        Route::rule('message', '/message'); //反馈信息
        Route::get('invitlist', '/invitlist'); //邀请列表等
        Route::rule('riderapply', '/riderapply'); //申请骑手
        Route::rule('promo', '/promo'); //申请骑手
        Route::get('getcount', '/getcount'); //申请骑手
        Route::get('getcount1', '/getcount1'); //申请骑手
        Route::post('keyend', '/keyend'); //使用key
        Route::post('recharge', '/recharge'); //使用key
        Route::post('buy_comobo', '/buy_comobo'); //使用key
    })->prefix('User');

    Route::group('Goods', function () {
        Route::get('cate', '/cate'); //用户登录
        Route::get('categoods', '/categoods'); //用户登录
        Route::get('goodsdetail', '/goodsdetail'); //用户登录
        Route::post('add_order', '/add_order'); //用户登录
        Route::get('order', '/order'); //用户登录
        Route::get('orderdetail', '/orderdetail'); //用户登录
        Route::get('cacelconfirm', '/cacelconfirm'); //用户登录
    })->prefix('Goods');

    Route::group('Other', function () {
        Route::get('getstreet', '/getstreet'); //获取定位信息
        Route::get('getconfig', '/getconfig'); //获取定位信息
        Route::get('addressjson', '/addressjson'); //获取地址库
        Route::rule('oss', '/oss'); //图片上传
        Route::get('street', '/street'); //获取街道列表
        Route::get('cate', '/cate'); //获取平台分类
        Route::get('subcate', '/subcate'); //获取平台分类
        Route::get('product', '/product'); //获取平台分类
        Route::get('banner', '/banner'); //获取平台分类
        Route::get('annous', '/annous'); //获取平台分类
        Route::rule('callback', '/callback'); //获取平台分类
        Route::rule('callback2', '/callback2'); //获取平台分类
        Route::rule('callback3', '/callback3'); //获取平台分类
        Route::rule('riderauth', '/riderauth'); //授权通知
        Route::rule('riderauth2', '/riderauth2'); //授权通知
        Route::get('comobo', '/comobo'); //授权通知
        Route::rule('getopenid', '/getopenid'); //授权通知
    })->prefix('Other');

    Route::group('Rider', function () {
        Route::post('Login', '/Login'); //用户登录
        Route::get('orderlist', '/orderlist'); //用户登录
        Route::get('orderdetail', '/orderdetail'); //用户登录
        Route::get('orders', '/orders'); //用户登录
        Route::rule('riderstreet', '/riderstreet'); //用户登录
        Route::post('setpassword', '/setpassword'); //用户登录
        Route::post('order_cat', '/order_cat'); //用户登录
        Route::post('orderlog_del', '/orderlog_del'); //用户登录
        Route::rule('message', '/message'); //用户登录
        Route::get('serrider', '/serrider'); //用户登录
        Route::post('returnorder', '/returnorder'); //用户登录
        Route::post('confirmorder', '/confirmorder'); //用户登录
        Route::post('payconfirmorder', '/payconfirmorder'); //用户登录
        Route::post('orderupload', '/orderupload'); //用户登录
        Route::get('rank', '/rank'); //用户登录
        Route::get('getstatus', '/getstatus'); //用户登录
        Route::get('getinfo', '/getinfo'); //用户登录
        Route::get('orderuplon', '/orderuplon'); //用户登录
    })->prefix('Rider');
})->bind('api')->prefix('api');
